package org.ilead.iserve.service.impl;

import java.util.List;

import org.ilead.iserve.dao.IUserVerifyAssociateDAO;
import org.ilead.iserve.model.UserVerifyAssociate;
import org.ilead.iserve.service.IUserVerifyAssociateService;

public class UserVerifyAssociateService implements IUserVerifyAssociateService {

	private IUserVerifyAssociateDAO userVerifyAssociateDAO;
	
	public void setUserVerifyAssociateDAO(
			IUserVerifyAssociateDAO userVerifyAssociateDAO) {
		this.userVerifyAssociateDAO = userVerifyAssociateDAO;
	}

	@Override
	public void add(UserVerifyAssociate associate) {
		userVerifyAssociateDAO.save(associate);
	}

	@Override
	public void deleteByUserId(Integer userId) {
		userVerifyAssociateDAO.deleteByUserId(userId);
	}

	@Override
	public UserVerifyAssociate findByUserId(Integer userId) {
		List<UserVerifyAssociate> list = userVerifyAssociateDAO.findByProperty(IUserVerifyAssociateDAO.USER_ID, userId);
		if(list == null || list.size() == 0)
			return null;
		return list.get(0);
	}

}
